import { Router, Route, Redirect, Switch } from "react-router-dom";
import "./App.scss";
import Login from "./pages/Login";
import Layout from "./pages/Layout";
import NotFound from "./pages/NotFound";
import ProfileEdit from "./pages/Profile/Edit";
import ProfileChat from "./pages/Profile/Chat";
import Article from "./pages/Home/components/Article";
import Search from "./pages/Search";
import SearchResult from "./pages/Search/Result";
import history from "./utils/history";
import AuthRoute from "./components/AuthRoute";

function App() {
  return (
    <Router history={history}>
      <div className="app">
        <Switch>
          <Route exact path="/" render={() => <Redirect to="/home"></Redirect>}></Route>
          <Route path="/home" component={Layout}></Route>
          <Route path="/login" component={Login}></Route>
          <Route path="/search" exact component={Search}></Route>
          <Route path="/search/result" component={SearchResult}></Route>
          <Route path="/article/:id" component={Article}></Route>
          <AuthRoute path="/profile/edit" component={ProfileEdit}></AuthRoute>
          <AuthRoute path="/profile/chat" component={ProfileChat}></AuthRoute>
          <Route component={NotFound}></Route>
        </Switch>
      </div>
    </Router>
  );
}

export default App;
